import { ecs } from "db://app-game/libs/ecs/ECS";
import { CameraModelComp } from "./model/CameraModelComp";
import { app } from "db://app-game/core/app";
import { Node, UITransform } from "cc";
/** 摄像机实例 */
@ecs.register("CameraEnt")
export class CameraEnt extends ecs.Entity {
  // 数据层
  CameraModel: CameraModelComp;

  // 视图层
  init() {
    this.add(CameraModelComp);
    this.CameraModel.cameraNode = app.gui.camera.node;
    const canvasUI = app.gui.root.getComponent(UITransform);
    this.CameraModel.renderWidth = canvasUI.width;
    this.CameraModel.renderHeight = canvasUI.height;
  }

  setfollowTarget(target: Node) {
    this.CameraModel.target = target;
  }
}
